package com.example.myapplication;

import android.graphics.Color;
import android.os.Bundle;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class TextViewUsageActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_text_view_usage);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
        // 通过代码设置文本的字体大小
        TextView text11 = findViewById(R.id.text11);
        // 文本的字体大小默认使用sp为单位
        text11.setTextSize(20);

        // 通过代码设置文本的颜色
        TextView text22 = findViewById(R.id.text22);
        text22.setTextColor(0xffff0000);

        // 通过代码设置文本的背景颜色
        findViewById(R.id.text25).setBackgroundColor(0xF0F30000);
    }
}